package main

import "fmt"

var i = 5
var str = "hahah"

type Person struct {
	name string
	age  int
}

// 空接口
type Any interface{}

func main() {
	var va1 Any //空接口
	va1 = 1
	fmt.Println(va1)
	va1 = str
	fmt.Println(va1)
	pers1 := new(Person)
	pers1.name = "lilei"
	pers1.age = 18
	va1 = pers1 //值类型
	fmt.Println(va1)
	switch t := va1.(type) {
	case int:
		fmt.Println("int %T\n", t)
	case string:
		fmt.Println("string %T\n", t)
	case *Person:
		fmt.Println("*Person %T\n", t)
	case bool:
		fmt.Println("bool %T\n", t)
	default:
		fmt.Println("unknown")
		panic("unknown") //运行时异常
	}
}
